Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the HTML encoding when uploading a folder in FF when using french… #460

Conversation

nickvergessen
Copy link
Member

… l10n

Fix #459

Please review @tflidd

@nickvergessen nickvergessen added this to the Nextcloud Next milestone Jul 20, 2016
@tflidd
Copy link
Contributor

tflidd commented Jul 20, 2016

That was a quick fix. Thank you, it works perfectly.
👍

message: data.errorThrown
});
}, undefined, {escape: false});
Copy link
Member

@LukasReschke LukasReschke Jul 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got to say that I consider this a kinda risky chance. While data.errorThrown may right now not echo back user controlled input this has still the potential to do bad things in the future… 🙈

Copy link
Member

@LukasReschke LukasReschke Jul 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do that at

data.errorThrown = t('files',
'Unable to upload {filename} as it is a directory or has 0 bytes',
{filename: file.name}
);
? Then we prevent the double escaping and don't introduce a XSS by mistake. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file name is already escaped there, it is also escaped here.
The problem is, that the actual translation contains the ', and when using that string here as a parameter in the translation, it is html encoded and displayes as &#...;. So not sure how this could be fixed on the other place, if this place breaks it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply unescape

data.errorThrown = t('files',
'Unable to upload {filename} as it is a directory or has 0 bytes',
{filename: file.name}
);
? Then the escaping here will take care of it, or do I miss something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha… Gotcha now… Let me think…

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unescape what? the unescape option only affects parameters, but the parameter is not the problem. Also the value in data.errorThrown here is not a problem, it's still what we would display in the UI. It's the t() method here, which takes the translated string as an argument and thereby s/'/&#..; the first translation. TO avoid this I removed escaping from all parameters and only escaped the file name, since the string here is only translator controlled, not user controlled, we can and have to trust it anyway....

Copy link
Member

@LukasReschke LukasReschke Jul 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. You're right. This is also properly escaped all since we don't use showHTML. (so even when passing HTML strings this shouldn't be rendered as HTML anyways)

@LukasReschke
Copy link
Member

👍

@LukasReschke LukasReschke merged commit b37e1ed into master Jul 20, 2016
@LukasReschke LukasReschke deleted the issue-459-html-decoded-error-message-when-uploading-folder branch July 20, 2016 12:31
@MorrisJobke
Copy link
Member

@nickvergessen @LukasReschke Backport?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants